/**
 * @name ConfigMockPlugin
 * @description 引入mockjs，本地模拟接口
 */
import { viteMockServe } from 'vite-plugin-mock';
import { getViteEnv } from '../utils';
export const ConfigMockPlugin = (isBuild: boolean, mode: string) => {
    return viteMockServe({
        ignore: /^\_/,
        mockPath: 'mock',
        //开发环境mock启动
        localEnabled: !isBuild,
        //实际开发请关闭，会影响打包体积
        prodEnabled: isBuild && getViteEnv(mode, 'VITE_BUILD_PROD_MOCK') === 'true',
        // https://github.com/anncwb/vite-plugin-mock/issues/9
        injectCode: `
       import { setupProdMockServer } from '../mock/_createProdMockServer';
       setupProdMockServer();
       `
    });
};
